import Vuex from 'vuex'
import Vue from "vue";


Vue.use(Vuex)

export default {

  state: {
    menuList: [],
    permList: [],
    hasRoute: false,
    editableTabsValue: 'Index',
    editableTabs: [
      {
        title: '首页',
        name: 'Index',
      }
    ],
  },

  mutations: {

    setMenuList(state , menus) {
      state.menuList = menus
    },

    setPermList(state , perm) {
      state.permList = perm
    },

    changeRouteStatus(state , hasRoute) {
      state.hasRoute = hasRoute
    },

    addTabsEdit(state, item) {
      if (item.name != "Home"){
        let index = state.editableTabs.findIndex(e => e.name === item.name )
        //console.log(item)
        if (index === -1){
          state.editableTabs.push({
            title: item.title,
            name: item.name,
          });
        }
        state.editableTabsValue = item.name;
      }

    },
    resetState: (state) => {
      console.log("清除了所有状态state数据")
      state.menuList = []
      state.permList = []
      state.hasRoute = false
      state.editableTabsValue = 'Index'
      state.editableTabs = [
        {
          title: '首页',
          name: 'Index',
        }
      ]
    }

  },

  actions: {},

}


